package com.eastmoney.emis.edda.infrastructure.hsbc.dto;

import com.eastmoney.emis.edda.domain.entity.EddaApply;
import com.eastmoney.emis.edda.domain.service.edda.EddaBindCommand;
import com.eastmoney.emis.edda.infrastructure.hsbc.annotation.HsbcEncrypt;
import com.eastmoney.emis.utils.common.sensitive.JsonSensitive;
import com.eastmoney.emis.utils.common.sensitive.JsonSerialize;
import com.eastmoney.emis.utils.common.sensitive.SensitiveType;
import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.infrastructure.dto
 * @author: 汪程程
 * @date: 2022/9/26 5:58 PM
 * @version: 1.0
 */
@HsbcEncrypt
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonSerialize
public class AuthReq {

    public String MerchantRequestIdentification;
    public String CreditorReference;
    public String UltimateDebtorName;
    public String DebtorName;
    public AccountDto DebtorAccount;
    public String CreditorName;
    public AccountDto CreditorAccount;
    @JsonSensitive(SensitiveType.ID_CARD)
    public String DebtorPrivateIdentification;
    public String DebtorPrivateIdentificationSchemeName;
    @JsonSensitive(SensitiveType.PHONE)
    public String DebtorMobileNumber;

    public String MaximumAmountCurrency;
    // 无限制
    public String MaximumAmount;
    public OccurrencesDto Occurrences = new OccurrencesDto();
    public boolean OtpHoldIndicator;
    public String SmsLanguageCode;


    public static class OccurrencesDto {
        public String FrequencyType = "ADHO";
        public String DurationFromDate = "";
        // 无限制
        public String DurationToDate = "9999-12-31";
    }
    
    public AuthReq() {}

    public AuthReq(EddaBindCommand command, com.eastmoney.emis.edda.config.CreditorAccount creditorAccount) {
        this.CreditorAccount = new AccountDto(creditorAccount);
        this.CreditorName = creditorAccount.getName();
        this.CreditorReference = command.getCreditorReference();

        AccountDto debtorAccount = new AccountDto();
        debtorAccount.Currency = "HKD";
        debtorAccount.AccountSchemeName = "BBAN";
        debtorAccount.BankCode = command.getBankCode();
        debtorAccount.AccountIdentification = command.getBankAccount();
        this.DebtorAccount = debtorAccount;

        this.DebtorName = command.getCustomEngName();
        this.UltimateDebtorName = command.getCustomEngName();
        this.DebtorMobileNumber = command.getMobile();
        this.DebtorPrivateIdentification = command.getDebtorPrivateId();
        this.DebtorPrivateIdentificationSchemeName = command.getDebtorPrivateIdSchemeName();
        this.MaximumAmountCurrency = "HKD";
        this.MaximumAmount = "99999999";
        this.OtpHoldIndicator = false;
        this.SmsLanguageCode = command.getLanguage();
    }

    public AuthReq(EddaApply eddaApply, com.eastmoney.emis.edda.config.CreditorAccount creditorAccount) {
        this.CreditorAccount = new AccountDto(creditorAccount);
        this.CreditorName = creditorAccount.getName();
        this.CreditorReference = eddaApply.getCreditReference();
        AccountDto debtorAccount = new AccountDto();
        debtorAccount.Currency = "HKD";
        debtorAccount.AccountSchemeName = "BBAN";
        debtorAccount.BankCode = eddaApply.getBankCode();
        debtorAccount.AccountIdentification = eddaApply.getBankAccount();
        this.DebtorAccount = debtorAccount;

        this.DebtorName = eddaApply.getCustomEngName();
        this.UltimateDebtorName = eddaApply.getCustomEngName();
        this.DebtorMobileNumber = eddaApply.getMobile();
        this.DebtorPrivateIdentification = eddaApply.getDebtorId();
        this.DebtorPrivateIdentificationSchemeName = eddaApply.getDebtorSchemeName();
        this.MaximumAmountCurrency = eddaApply.getCurrency();
        this.MaximumAmount = eddaApply.getMaximumAmount();
        this.OtpHoldIndicator = false;
        this.SmsLanguageCode = eddaApply.getLanguage();
        this.MerchantRequestIdentification = eddaApply.getRegisterId();
    }
}
